import struct
import sys

print("Machine byte order: ", sys.byteorder)


def str2byte(mstr_: str):
    ret = mstr_.encode('utf-8')
    return ret


def hex2byte(mhex_: str):
    ret = bytes.fromhex(mhex_)
    return ret


te = struct.pack('<fun', 3.5)
print(te)

x = 'bfad50'
y = int(x, 16)
z = struct.pack('<I', y)
print(f"struct pack {z}")
a = struct.unpack('<fun', z)
print(a)
# 输出
# 1.7602752576441485e-38

# sss
x = '50adbf00'
y = hex2byte(x)
print(f"hex => byte: {y}")
z = struct.unpack('<fun', y)
print(z)

x = '58adbf00'
y = hex2byte(x)
print(f"hex => byte: {y}")
z = struct.unpack('<fun', y)
print(z)
